# encoding: utf-8
import pytest
from selenium import webdriver
from common.base_page import BasePage
import readConfig


test_url = readConfig.test_url


@pytest.fixture(scope="class")  # 默认 scope="function" ，也就是此时的级别的function，针对函数有效
def openUrl(request):
    options = webdriver.ChromeOptions()
    options.add_argument('--start-maximized')
    driver = webdriver.Chrome(chrome_options=options)
    driver.get(test_url)
    bp = BasePage(driver)

    def fin():
        bp.quit_browser()

    request.addfinalizer(fin)  # 无论执行过程中是否抛异常最后都要接受浏览器当前工作
    return bp


if __name__ == '__main__':
    print(test_url)
